<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>写入开始位置以及 exe 类型文件的结尾信号</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.bcompiler-write-exe-footer" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">bcompiler_write_exe_footer</h1>
  <p class="verinfo">(PECL bcompiler &gt;= 0.4)</p><p class="refpurpose"><span class="refname">bcompiler_write_exe_footer</span> &mdash; <span class="dc-title">写入开始位置以及 exe 类型文件的结尾信号</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.bcompiler-write-exe-footer-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>bcompiler_write_exe_footer</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$filehandle</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$startpos</code></span>
   ) : <span class="type">bool</span></div>

  <p class="para rdfs-comment">
    一个 EXE（或可自执行）文件由 3 部分组成：
   <ul class="simplelist">
    <li class="member">
     The <em>stub</em> （可执行代码，例如一个编译过的 c 程序）
     加载了 PHP 解释器、bcompiler 扩展、储存的字节码并初始化调用指定函数（例如 main）
     或类的方法（例如 <em>main::main</em>）。
    </li>
    <li class="member">字节码（仅在那时未压缩）</li>
    <li class="member">bcompiler 的 EXE 尾部</li>
   </ul>
  </p>
  <p class="para">
   为了得到适合的 stub 你可以编译位于 bcompiler CVS <var class="filename">examples/embed</var> 目录里
   基于 php_embed 的 stub <var class="filename">phpe.c</var>。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.bcompiler-write-exe-footer-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">filehandle</code></dt>

     <dd>

      <p class="para">
       <span class="function"><a href="fopen.html" class="function">fopen()</a></span>返回的一个文件句柄。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">startpos</code></dt>

     <dd>

      <p class="para">
       字节码在文件中开始的位置，可以通过 <span class="function"><a href="ftell.html" class="function">ftell()</a></span> 获取。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.bcompiler-write-exe-footer-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.bcompiler-write-exe-footer-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-448">
    <p><strong>Example #1 <span class="function"><strong>bcompiler_write_exe_footer()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*&nbsp;创建输出的文件（example.exe）&nbsp;*/<br /></span><span style="color: #0000BB">$fh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">"example.exe"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"w"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;1)&nbsp;写入一个&nbsp;stub&nbsp;（phpe.exe）&nbsp;*/<br /></span><span style="color: #0000BB">$size&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">filesize</span><span style="color: #007700">(</span><span style="color: #DD0000">"phpe.exe"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$fr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">"phpe.exe"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"r"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$fh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">fread</span><span style="color: #007700">(</span><span style="color: #0000BB">$fr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$size</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">$size</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$startpos&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ftell</span><span style="color: #007700">(</span><span style="color: #0000BB">$fh</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;2)&nbsp;写入字节码&nbsp;*/<br /></span><span style="color: #0000BB">bcompiler_write_header</span><span style="color: #007700">(</span><span style="color: #0000BB">$fh</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">bcompiler_write_class</span><span style="color: #007700">(</span><span style="color: #0000BB">$fh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"myclass"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">bcompiler_write_function</span><span style="color: #007700">(</span><span style="color: #0000BB">$fh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"main"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">bcompiler_write_footer</span><span style="color: #007700">(</span><span style="color: #0000BB">$fh</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;3)&nbsp;写入&nbsp;EXE&nbsp;尾部&nbsp;*/<br /></span><span style="color: #0000BB">bcompiler_write_exe_footer</span><span style="color: #007700">(</span><span style="color: #0000BB">$fh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$startpos</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;关闭输出的文件&nbsp;*/<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fh</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.bcompiler-write-exe-footer-notes">
  <h3 class="title">注释</h3>
  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">此函数是<em class="emphasis">实验性</em>的。此函数的表象，包括名称及其相关文档都可能在未来的
PHP 发布版本中未通知就被修改。使用本函数风险自担 。</p></div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.bcompiler-write-exe-footer-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="bcompiler_write_header.html" class="function" rel="rdfs-seeAlso">bcompiler_write_header()</a> - 写入 bcompiler 头</span></li>
    <li class="member"><span class="function"><a href="bcompiler_write_class.html" class="function" rel="rdfs-seeAlso">bcompiler_write_class()</a> - 写入定义过的类的字节码</span></li>
    <li class="member"><span class="function"><a href="bcompiler_write_footer.html" class="function" rel="rdfs-seeAlso">bcompiler_write_footer()</a> - 写入单个字符 \x00 用于标识编译数据的结尾</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>